package com.snow.model;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

/**
 * 统计折线图模型
 *
 * @param <T> 类型 数据类型，一般为 Long或 Decimal
 */

@Getter
@Setter
public class StatisticsGraphicsPolylineModel<T> {
    private List<String> x = new ArrayList<>();
    private List<String> y = new ArrayList<>();
    private List<Item<T>> series = new ArrayList<>();

    @Getter
    @Setter
    @AllArgsConstructor
    public static class Item<T> {
        private String name;
        private List<T> data;

    }

    public StatisticsGraphicsPolylineModel<T> addXAxis(String name) {
        this.x.add(name);
        return this;
    }

    public StatisticsGraphicsPolylineModel<T> addSeries(String name, List<T> data) {
        this.series.add(new Item<>(name, data));
        return this;
    }
}
